//
//  YJQSportCameraMaskView.m
//  GoodLuck
//
//  Created by 杨瑞 on 17/2/21.
//  Copyright © 2017年 杨瑞. All rights reserved.
//

#import "YJQSportCameraMaskView.h"
#import "UIColor+YJQAddition.h"

@interface YJQSportCameraMaskView()
@property (nonatomic, weak) IBOutlet UIImageView *imageView;
@end

@implementation YJQSportCameraMaskView

-(void)drawRect:(CGRect)rect {
    {
        [[UIColor yjq_colorWithHex:0x24282e] setFill];
        UIBezierPath *path = [UIBezierPath bezierPathWithRect:rect];
        [path fill];
    }
    // 2. 绘制中间的直线
    {
        UIBezierPath *path = [UIBezierPath bezierPath];
        if (_imageView.frame.origin.x > 0) {
            [path moveToPoint:CGPointMake(rect.size.width, 0)];
            [path addLineToPoint:CGPointMake(rect.size.width, rect.size.height)];
        }else {
            [path moveToPoint:CGPointMake(0, 0)];
            [path addLineToPoint:CGPointMake(0, rect.size.height)];
        }
        [[UIColor yjq_colorWithHex:0x1a1a1a] setStroke];
        [path stroke];
    }
    // 3. 核心绘图的清除区域的函数 - 注意：视图背景颜色需要是 clearColor
    CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectInset(_imageView.frame, 1, 1));
}

@end
